<template>
	<div class="wrapper">

		<!--header-->
		<header>
			<div class="icon-location-box">
				<div class="icon-loc"></div>
				<!--<div class="icon pin"></div>-->
			</div>
			<div class="location-text">神椿市<i class="fa fa-caret-down"></i></div>
		</header>

		<!--search-->
		<div class="search">
			<div class="search-fixed-top" ref="fixedBox">
				<div class="search-box">
					<i class="fa fa-search"></i>搜索饿了么商家、商品名称
				</div>
			</div>
		</div>

		<!--foodtype-->
		<!--ul  ol 是HTML里的数组-->
		<ul class="foodtype">
			<li @click="toBusinessList(1)">
				<img src="../assets/dcfl01.png">
				<p>美食</p>
			</li>
			<li @click="toBusinessList(2)">
				<img src="../assets/dcfl02.png">
				<p>早餐</p>
			</li>
			<li @click="toBusinessList(3)">
				<img src="../assets/dcfl03.png">
				<p>跑腿代购</p>
			</li>
			<li @click="toBusinessList(4)">
				<img src="../assets/dcfl04.png">
				<p>汉堡披萨</p>
			</li>
			<li @click="toBusinessList(5)">
				<img src="../assets/dcfl05.png">
				<p>甜品饮品</p>
			</li>
			<li @click="toBusinessList(6)">
				<img src="../assets/dcfl06.png">
				<p>速食简餐</p>
			</li>
			<li @click="toBusinessList(7)">
				<img src="../assets/dcfl07.png">
				<p>地方小吃</p>
			</li>
			<li @click="toBusinessList(8)">
				<img src="../assets/dcfl08.png">
				<p>米粉面馆</p>
			</li>
			<li @click="toBusinessList(9)">
				<img src="../assets/dcfl09.png">
				<p>包子粥铺</p>
			</li>
			<li @click="toBusinessList(10)">
				<img src="../assets/dcfl10.png">
				<p>炸鸡炸串</p>
			</li>
		</ul>

		<!--banner-->
		<div class="banner" @click="toBusinessInfo()">
			<h3>品质套餐</h3>
			<p>搭配齐全吃得好</p>
			<a>立即抢购 &gt;</a>
		</div>

		<!--supermember-->
		<div class="supermember">
			<div class="supermember-left">
				<img src="../assets/super_member.png" />
				<h3>超级会员</h3>
				<p>&#8226; 每月享超值权益</p>
			</div>
			<div class="supermember-right">
				立即开通 &gt;
			</div>
		</div>

		<!--recommend-->
		<div class="recommend" @click="toBusinessLst(1)">
			<div class="rcmd-line"></div>
			<p>推荐商家</p>
			<div class="rcmd-line"></div>
		</div>

		<!--recommend type-->
		<ul class="rctype">
			<li>综合排序<i class="fa fa-caret-down"></i></li>
			<li>距离最近</li>
			<li>销量最高</li>
			<li>筛选 <i class="fa fa-filter"></i></li>
		</ul>

		<!--business-->
		<ul class="business">
			<li @click="toBusinessInf(10001)">
				<img src="../assets/sj01.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>万家饺子（软件园E18店）</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<li>
				<img src="../assets/sj02.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>小锅饭豆腐馆（全运店）</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<li>
				<img src="../assets/sj03.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>麦当劳麦乐送（全运路店）</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<li>
				<img src="../assets/sj04.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>米村拌饭（浑南店）</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<li>
				<img src="../assets/sj05.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>申记串道（中海康城店）</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<li>
				<img src="../assets/sj06.png">
				<div class="bsns-info">
					<div class="bsns-info-h">
						<h3>半亩良田排骨米饭</h3>
						<div class="bsns-info-like">&#8226;</div>
					</div>
					<div class="bsns-info-star">
						<div class="bsns-info-star-l">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<p>4.9 月售345单</p>
						</div>
						<div class="bsns-info-star-r">
							蜂鸟专送
						</div>
					</div>
					<div class="bsns-info-delivery">
						<p>&#165;15起送 | &#165;3配送</p>
						<p>3.22km | 30分钟</p>
					</div>
					<div class="bsns-info-explain">
						<div>各种饺子</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="bsns-info-promotion-r">
							<p>2个活动</p>
							<i class="fa fa-caret-down"></i>
						</div>
					</div>
					<div class="bsns-info-promotion">
						<div class="bsns-info-promotion-l">
							<div class="bsns-info-promotion-l-icon" style="background-color: #F1884F;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
		</ul>

		<!--footer-->
		<Footer></Footer>
	</div>
</template>


<script>
	//导入共同组件
	import Footer from "@/components/Footer.vue";
	
	export default {
		name: 'Index',
		mounted() {
			document.onscroll = () => {
				// 获取滚动条位置
				let s1 = document.documentElement.scrollTop;
				let s2 = document.body.scrollTop;
				let scroll = s1 == 0 ? s2 : s1;
				// 获取视口宽度
				let width = document.documentElement.clientWidth;
				// 获取固定块
				let search = this.$refs.fixedBox;
				// 判断滚动条超过12%时将搜索框变为固定
				if (scroll > width * 0.12) {
					search.style.position = 'fixed';
					search.style.left = '0';
					search.style.top = '0';
				} else {
					search.style.position = 'static';
				}
			};
		},
		destroyed(){
			document.onscroll = null;//切换到其他组件时，去除此事件
		},
		components:{
			Footer
		},
		methods:{
			toBusinessList(orderTypeId){
				document.onscroll = null;
				this.$router.push({path:'/businessList',query:{orderTypeId:orderTypeId}});
			},
			toBusinessLst(orderTypeId){
				document.onscroll = null;
				this.$router.push({path:'/businessListe',query:{orderTypeId:orderTypeId}});
			},
			toBusinessInfo(){
				document.onscroll = null;
				this.$router.push({path:'/businessInfo'});
			},
			toBusinessInf(businessId){
				document.onscroll = null;
				this.$router.push({path:'/businessInfo',query:{businessId:businessId}});
			}
		}
	};
</script>




<style scoped>
	/*testtesttest*/
	/****************总容器*********************/

	.wrapper {
		width: 100%;
		height: 100%;

	}

	/****************header*********************/

	.wrapper header {
		width: 100%;
		height: 12vw;
		background-color: #0097FF;

		display: flex;
		align-items: center;
	}

	.wrapper header .icon-location-box {
		width: 3.5vw;
		height: 3.5vw;
		margin: 0 1vw 0 3vw;
	}

	.wrapper header .location-text {
		font-size: 4.5vw;
		font-weight: 700;
		color: #fff;
	}

	.wrapper header .location-text .fa-caret-down {
		margin-left: 1vw;
	}

	/************* search **************/

	.wrapper .search {
		width: 100%;
		height: 13vw;
	}

	.wrapper .search .search-fixed-top {
		width: 100%;
		height: 13vw;
		background-color: #0097FF;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.wrapper .search .search-fixed-top .search-box {
		width: 90%;
		height: 9vw;
		background-color: #FFFFFF;
		border-radius: 2px;
		/*圆角*/

		display: flex;
		justify-content: center;
		align-items: center;

		font-size: 3.5vw;
		color: #AEAEAE;
		font-family: "宋体";
		user-select: none;
		/*让文本选中状态无效*/
	}

	.wrapper .search .search-fixed-top .search-box .fa-search {
		margin-right: 1vw;
	}

	/************* foodtype **************/
	.wrapper .foodtype {
		width: 100%;
		height: 48vw;

		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
		align-content: center;
	}

	.wrapper .foodtype li {
		width: 18vw;
		/*16.7-20之间*/
		height: 20vw;

		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		user-select: none;
		cursor: pointer;
	}

	.wrapper .foodtype li img {
		width: 12vw;
		height: 12vw;
	}

	.wrapper .foodtype li p {
		font-size: 3.2vw;
		color: #666;
	}

	/**********banner***********/

	.wrapper .banner {
		width: 95%;
		margin: 0 auto;
		/*传统水平居中*/
		height: 29vw;

		background-image: url(../assets/index_banner.png);
		/*背景图片自适应充满框*/
		background-repeat: no-repeat;
		background-size: cover;

		box-sizing: border-box;
		padding: 2vw 6vw;
	}

	.wrapper .banner h3 {
		font-size: 4.2vw;
		margin-bottom: 1.2vw;
	}

	.wrapper .banner p {
		font-size: 3.4vw;
		color: #666666;
		margin-bottom: 2.4vw;
	}

	.wrapper .banner a {
		font-size: 3vw;
		color: #c79060;
		font-weight: 700;
	}

	/**********super member***********/
	.wrapper .supermember {
		width: 95%;
		height: 11.5vw;
		margin: 0 auto;
		background-color: #FEEDC1;
		margin-top: 1.3vw;
		border-radius: 2px;
		color: #644F1B;

		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.wrapper .supermember .supermember-left {
		display: flex;
		align-items: center;
		margin-left: 4vw;
		user-select: none;
	}

	.wrapper .supermember .supermember-left img {
		width: 6vw;
		height: 6vw;
		margin-right: 2vw;
	}

	.wrapper .supermember .supermember-left h3 {
		font-size: 4vw;
		margin-right: 2vw;
	}

	.wrapper .supermember .supermember-left p {
		font-size: 3vw;
	}

	.wrapper .supermember .supermember-right {
		font-size: 3vw;
		margin-right: 4vw;
		cursor: pointer;
	}

	/***************recommend****************/

	.wrapper .recommend {
		width: 100%;
		height: 14vw;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.wrapper .recommend .rcmd-line {
		width: 6vw;
		height: 0.3vw;
		background-color: #888888;
	}

	.wrapper .recommend p {
		font-size: 4vw;
		margin: 0 4vw;
	}

	/***************recommend type****************/

	.wrapper .rctype {
		width: 100%;
		height: 5vw;
		margin-bottom: 5vw;

		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.wrapper .rctype li {
		font-size: 3.5vw;
		color: #555555;
	}

	/***************business****************/
	.wrapper .business {
		/* display: inline-block;
		width: 100%;
		margin-bottom: 14vw; */
		padding-bottom: 14vw;
		width: 100%;
	}

	.wrapper .business li {
		width: 100%;
		box-sizing: border-box;
		/*边框盒子*/
		padding: 2.5vw;
		/*内边距*/
		user-select: none;
		border-bottom: solid 1px #DDDDDD;

		display: flex;
	}

	.wrapper .business li img {
		width: 18vw;
		height: 18vw;
	}

	.wrapper .business li .bsns-info {
		width: 100%;
		box-sizing: border-box;
		padding-left: 3vw;
	}

	.wrapper .business li .bsns-info .bsns-info-h {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
	}

	.wrapper .business li .bsns-info .bsns-info-h h3 {
		font-size: 4vw;
		color: #333333;
	}

	.wrapper .business li .bsns-info .bsns-info-h .bsns-info-like {
		width: 1.6vw;
		height: 3.4vw;
		background-color: #666666;
		color: #FFFFFF;
		font-size: 4vw;
		margin-right: 4vw;

		display: flex;
		align-items: center;
		justify-content: center;
	}

	.wrapper .business li .bsns-info .bsns-info-star {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
		font-size: 3.1vw;
	}

	.wrapper .business li .bsns-info .bsns-info-star .bsns-info-star-l {
		display: flex;
		align-items: center;
	}

	.wrapper .business li .bsns-info .bsns-info-star .bsns-info-star-l .fa-star {
		color: #FEC80E;
		margin-right: 0.5vw;
	}

	.wrapper .business li .bsns-info .bsns-info-star .bsns-info-star-l p {
		color: #666666;
		margin-left: 1vw;
	}

	.wrapper .business li .bsns-info .bsns-info-star .bsns-info-star-r {
		background-color: #0097FF;
		color: #FFFFFF;
		font-size: 2.4vw;
		border-radius: 2px;
		padding: 0 0.6vw;
		/*设了内边距但是没设边框盒子 是因为没有确定宽和高*/
	}

	.wrapper .business li .bsns-info .bsns-info-delivery {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;

		color: #666666;
		font-size: 3.1vw;
	}

	.wrapper .business li .bsns-info .bsns-info-explain {
		display: flex;
		align-items: center;
		margin-bottom: 3vw;
	}

	.wrapper .business li .bsns-info .bsns-info-explain div {
		border: solid 1px #DDDDDD;
		font-size: 2.8vw;
		color: #666666;
		border-radius: 3px;
		padding: 0 0.1vw;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 1.8vw;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion .bsns-info-promotion-l {
		display: flex;
		align-items: center;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion .bsns-info-promotion-l .bsns-info-promotion-l-icon {
		width: 4vw;
		height: 4vw;
		background-color: #70BC46;
		color: #FFFFFF;
		border-radius: 3px;
		font-size: 3vw;

		display: flex;
		justify-content: center;
		align-items: center;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion .bsns-info-promotion-l p {
		color: #666666;
		font-size: 3vw;
		margin-left: 2vw;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion .bsns-info-promotion-r {
		display: flex;
		align-items: center;
		font-size: 2.5vw;
		color: #999999;
	}

	.wrapper .business li .bsns-info .bsns-info-promotion .bsns-info-promotion-r p {
		margin-right: 2vw;
	}
</style>
